import { IEditFormModel } from '@/core';
function getModel(): IEditFormModel {
    return {
        name: "{{ctrl.name}}",
        caption: "{{ctrl.caption}}",
        codeName: "{{ctrl.codeName}}",
        enableAutoSave: {{#if ctrl.enableAutoSave}}{{ctrl.enableAutoSave}}{{else}}false{{/if}},
        entityCodeName: "{{ctrl.psAppDataEntity.codeName}}",
        keyPSAppDEField: "{{ctrl.psAppDataEntity.keyPSAppDEField.codeName}}",
        majorPSAppDEField: "{{ctrl.psAppDataEntity.majorPSAppDEField.codeName}}",
        cssName: "{{#if ctrl.psSysCss}}{{ctrl.psSysCss.cssName}}{{/if}}",
        controlType: "{{ctrl.controlType}}",
        formStyle: "{{ctrl.formStyle}}",
        valueRule: getValueRule(),
        createDefaultItems: getCreateDefaultItems(),
        updateDefaultItems: getUpdateDefaultItems(),
        detailModel: getDetailModel(),
    }
}
function getValueRule() {
    return [
        {{#each ctrl.psDEFormItemVRs as | ruleItem |}}
        {{#neq ruleItem.checkMode 2}}
        {
            name: "{{ruleItem.psDEFormItemName}}",
            valueRuleType: "{{ruleItem.valueRuleType}}",
            checkMode: {{ruleItem.checkMode}},
            {{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
            {{#if ruleItem.psSysValueRule.regExCode}}
            regExCode: /{{ruleItem.psSysValueRule.regExCode}}/,
            {{/if}}
            ruleInfo: "{{ruleItem.psSysValueRule.ruleInfo}}",
            ruleType: "{{ruleItem.psSysValueRule.ruleType}}",
            scriptCode: `{{ruleItem.psSysValueRule.scriptCode}}`
            {{else if (eq ruleItem.valueRuleType 'DEFVALUERULE')}}
            ruleInfo: "{{ruleItem.psDEFValueRule.ruleInfo}}",
            condition:  {{> @macro/common/derules.hbs item=ruleItem.psDEFValueRule.psDEFVRGroupCondition}}
            {{~/if}}
        }{{~#unless @last}},{{/unless}}
        {{/neq}}
        {{/each}}
    ]
}
function getCreateDefaultItems() {
    return [
{{#each ctrl.psDEFormItems as | formItem |}}
    {{#formItem}}
        {{#if (or createDV createDVT)}}
        {
            createDV: "{{createDV}}",
            createDVT: "{{createDVT}}",
            property: "{{lowerCase id}}",
            {{#if (and psEditor psEditor.dateTimeFormat)}}
            valueFormat: "{{editItem.psEditor.dateTimeFormat}}",
            {{else if psAppDEField}}
            valueFormat: "{{psAppDEField.valueFormat}}",
            {{/if~}}
            dataType: {{dataType}},
        }{{#unless @last}},{{/unless}}
        {{/if}}
    {{/formItem}}
{{/each}}
    ]
}
function getUpdateDefaultItems() {
    return [
{{#each ctrl.psDEFormItems as | formItem |}}
    {{#formItem}}
        {{#if (or updateDV updateDVT)}}
        {
            updateDV: "{{updateDV}}",
            updateDVT: "{{updateDVT}}",
            property: "{{lowerCase id}}",
            {{#if (and psEditor psEditor.dateTimeFormat)}}
            valueFormat: "{{editItem.psEditor.dateTimeFormat}}",
            {{else if psAppDEField}}
            valueFormat: "{{psAppDEField.valueFormat}}",
            {{/if~}}
            dataType: {{dataType}},
        }{{#unless @last}},{{/unless}}
        {{/if}}
    {{/formItem}}
{{/each}}    
    ]
}
function getDetailModel() {
    return {
{{#if ctrl.psDEFormPages}}
    {{#each ctrl.psDEFormPages as | FormPage | }}
        {{> @macro/widgets/form-detail/include-form.hbs type="FORMDETAILSMODEL" item=FormPage}}
    {{/each}}
{{/if}}
    }
}
export const model = getModel();
